/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Util;

/**
 *
 * @author Jack
 */
import Database.*;
import java.sql.*;
import java.util.Vector;

public class Status {

    private int idstatus;
    private String namestatus;

    /**
     * @return the idstatus
     */
    public int getIdstatus() {
        return idstatus;
    }

    /**
     * @param idstatus the idstatus to set
     */
    public void setIdstatus(int idstatus) {
        this.idstatus = idstatus;
    }

    /**
     * @return the namestatus
     */
    public String getNamestatus() {
        return namestatus;
    }

    /**
     * @param namestatus the namestatus to set
     */
    public void setNamestatus(String namestatus) {
        this.namestatus = namestatus;
    }

    public Vector<Status> ListStatus() {
        Vector<Status> listd = new Vector<Status>();
        try {
            Connection con = ConnectToDatabase.getConnection();
            String query = "select * from Status";
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery(query);
            while (rs.next()) {
                Status d = new Status();
                d.setIdstatus(rs.getInt("idstatus"));
                d.setNamestatus(rs.getString("namestatus"));
                listd.add(d);
            }
        } catch (Exception e) {
            listd = null;
        }
        return listd;
    }

    public static String ListStatus(int a) {
        String liste = "";
        try {
            Connection con = ConnectToDatabase.getConnection();
            String query = "select namestatus from status,bugreport where bugreport.idstatus=status.idstatus and bugreport.idreport=" + a;
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery(query);
            while (rs.next()) {
                liste = rs.getString("namestatus");
            }
        } catch (Exception ex) {
            liste = null;
        }
        return liste;
    }
}
